class Solution
{
public:
    int countKeyChanges(string s)
    {
        int result = 0;
        int n = s.size();
        if (s[0] >= 'A' && s[0] <= 'Z')
        {
            s[0] = s[0] - 'A' + 'a';
        }
        for (int i = 1; i < n; ++i)
        {
            if (s[i] >= 'A' && s[i] <= 'Z')
            {
                s[i] = s[i] - 'A' + 'a';
            }
            if (s[i] != s[i - 1])
            {
                ++result;
            }
        }
        return result;
    }
};